SET(CMAKE_INCLUDE_CURRENT_DIR ON)

SET(ChOR_ENABLE_CPP_RTTI TRUE)
INCLUDE("../cxx_flag_overrides.cmake")
SET(ChOR_ENABLE_CPP_RTTI)

SET(SOURCES
CppNpObject.cpp
CppNpObject.h
PyNpObject.cpp
PyNpObject.h
main.cpp
)

# TODO should have a FindChromium.cmake file
# 
SET( CHROMIUM_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/../Chromium/src" )

# TODO should have a FindPython.cmake file
# 
SET( PYTHON_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/../../../sdk/Python26" )

INCLUDE_DIRECTORIES("../Awesomium")
INCLUDE_DIRECTORIES("${CHROMIUM_ROOT}")
INCLUDE_DIRECTORIES("${CHROMIUM_ROOT}/third_party/npapi")
INCLUDE_DIRECTORIES("${PYTHON_ROOT}/include")
INCLUDE_DIRECTORIES(${RTGUBoost_INCLUDE_DIRS})

LINK_DIRECTORIES("${CHROMIUM_ROOT}/build/${CMAKE_CFG_INTDIR}/lib")
LINK_DIRECTORIES("${PYTHON_ROOT}/libs")
LINK_DIRECTORIES(${RTGUBoost_LIBRARIES})

ADD_LIBRARY(pyAwesomium SHARED ${SOURCES})

SET_TARGET_PROPERTIES( pyAwesomium
	PROPERTIES
	SUFFIX ".pyd"
	DEBUG_POSTFIX ""
)

TARGET_LINK_LIBRARIES( pyAwesomium Awesomium ) 

##
## COPY CHROMIUM DLLs to ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}
##

SET(CHROMIUM_DLLS
avcodec-52.dll
avformat-52.dll
avutil-50.dll
chrome.dll
icudt42.dll
)

SET(COPY_CHROMIUM_TGT Awesomium_copy_files)
ADD_CUSTOM_TARGET(${COPY_CHROMIUM_TGT} ALL COMMENT "Copying Awesomium chromium files")

foreach(FILENAME ${CHROMIUM_DLLS})

	SET(SRC "${CHROMIUM_ROOT}/build/${CMAKE_CFG_INTDIR}/${FILENAME}")
	SET(DST "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}/${FILENAME}")
	
	add_custom_command(
		TARGET ${COPY_CHROMIUM_TGT}
		COMMAND ${CMAKE_COMMAND} -E copy ${SRC} ${DST}
	)
	
endforeach(FILENAME)

ADD_DEPENDENCIES( pyAwesomium ${COPY_CHROMIUM_TGT} )
